<template>
<div  class="container ">   
    <Loading></Loading>
    <div class="top">
    <pageHeader :toggleClick='HeadtoggleClick'></pageHeader><!--页头-->
    </div>      
    <div class="layout" :class="{'layout-hide-text': spanLeft < 4}">
        <Row type="flex" style="height: 100% !important;">
            <Col :span="spanLeft" class="layout-menu-left">
                <!-- <div class="menuTop">
                    <Button type="text" @click="HeadtoggleClick" style="float:right">
                        <Icon type="navicon" size="40" color="#000000"></Icon>
                        <Icon type="navicon"  size="60" color="#FFFFFF"></Icon>
                    </Button>   
                </div>  -->
                <div style="width:100%;overflow-x:hidden;overflow-y:auto;height: 95%;border:none;">
                    <pageMenu :datalist='MenuList' :leftsize='spanLeft'></pageMenu><!--菜单-->
                </div>
            </Col>
            <Col :span="spanRight" class="layout-right">
                <pageBreadcrumb></pageBreadcrumb>
                <div class="layout-content">
                    <router-view></router-view> 
                </div>
            </Col>
        </Row> 
    </div>
    <pageFooter></pageFooter><!--页尾-->
</div>
</template>
<script>
 export default {
        name:'home',
        data:function(){
            return{
                currentMenu:'',//当前菜单名称
                MenuList: [],//菜单列表
                spanLeft: 4,
                spanRight: 20
            }
        },
        // mounted() {
        //     new JParticles.particle('#particles', {
        //         color: '#FFFFFF',
        //         range: 10,
        //         proximity: 100,
        //         parallax: true,
        //         parallaxStrength: 1
        //     });
        // },
        methods: {
            initMenu() {
                var user = this.GetlocaStorage("VegUserInfo");
                var userModel = new Object();
                var self = this;
                this.$http.get('Menu', { params: { UserId: user.UserId, Account: user.Account } }).then(function (res) {

                    switch (res.data.status) {
                        case 0:
                            self.$Modal.info({ title: "提示信息", content: res.data.message, desc: false });
                            break;
                        case 1:
                            self.MenuList = res.data.model;
                            break;
                        case -1:
                            self.$Modal.warning({ title: "提示信息", content: "修改失败,请与管理员联系!" });
                            break;
                    }
                });
            },

             HeadtoggleClick () {//菜单关闭和展开
                if (this.spanLeft === 4) {
                    this.spanLeft = 2;
                    this.spanRight = 22;
                } else {
                    this.spanLeft = 4;
                    this.spanRight = 20;
                }
            },
            checkLogin:function(){//登录检测
                var userInfo=this.GetlocaStorage("VegUserInfo");              
                if(userInfo==null||userInfo==undefined){
                    //如果没有登录状态则跳转到登录页
                    this.$router.push('/login');
                }else{
                    //否则跳转到登录后的页面
                    this.$router.push('/home');
                    }
                }
            },
            computed: {
              user(){//当前用户获取
                return this.GetlocaStorage("VegUserInfo");       
            }   
        },
        created(){//系统初始化，首先进行登录验证
            // this.checkLogin();
            this.initMenu();
        }
    }
</script>
